<template>
  <div class="health-garden">
    <div class="header-bg">
      <img src="../assets/page/jiankang.png" alt="">
    </div>
    <div class="tabs-panel">
      <ul class="tabs">
        <li :class="liclass==1 ? 'liactive' : ''" @click="changeli(1)">小常识</li>
        <li :class="liclass==2 ? 'liactive' : ''" @click="changeli(2)">部分食物热量表</li>
        <li :class="liclass==3 ? 'liactive' : ''" @click="changeli(3)">体重计算公式</li>
      </ul>
    </div>
    <div class="changshi content" v-if="liclass==1">
      <div v-show="!isDetail" class="newsdiv" v-for="item in newslist" :key="item.id">
        <div class="neirong">
          <span>{{item.title}}</span>
          <span>{{item.content}}</span>
        </div>
        <span class="liaojie" @click="gotoDetail(item.id)">点击了解详情</span>
      </div>
      <div v-show="isDetail" class="detailcont">
        <!-- <singlenews></singlenews> -->
      </div>
    </div>
    <div class="reliang content" v-if="liclass==2">
      <newfoodheat></newfoodheat>
      <!-- <img src="../assets/page/shuju.png" alt=""> -->
    </div>
    <div class="jisuan content" v-if="liclass==3">
      <newweight></newweight>
      <!-- <img src="../assets/page/gongshi.png" alt=""> -->
    </div>
  </div>
</template>

<script>
// import singlenews from './singlenews'
import newfoodheat from './newfoodheat'
import newweight from './newweight'
  export default {
    components: {
      // singlenews,
      newfoodheat,
      newweight
    },
    data() {
      return {
        liclass: 1,
        isDetail: false,
        newslist: [{
          id:123,
          title: "小常识",
          content: "随着生活水平的不断提高，人们的饮食习惯已发生了很大的改变，人们对高热量、高脂肪、高蛋白食品和精细食品的摄入量大大增加，许多大中城市特别是经济比较发达的城市均出现了膳食纤维摄入量不足、营养素摄入不……"
        }
        // ,{
        //   id:124,
        //   title: "小常识2",
        //   content: "随着生活水平的不断提高，人们的饮食习惯已发生了很大的改变，人们对高热量、高脂肪、高蛋白食品和精细食品的摄入量大大增加，许多大中城市特别是经济比较发达的城市均出现了膳食纤维摄入量不足、营养素摄入不……"
        // },{
        //   id:125,
        //   title: "小常识3",
        //   content: "随着生活水平的不断提高，人们的饮食习惯已发生了很大的改变，人们对高热量、高脂肪、高蛋白食品和精细食品的摄入量大大增加，许多大中城市特别是经济比较发达的城市均出现了膳食纤维摄入量不足、营养素摄入不……"
        // },{
        //   id:126,
        //   title: "小常识4",
        //   content: "随着生活水平的不断提高，人们的饮食习惯已发生了很大的改变，人们对高热量、高脂肪、高蛋白食品和精细食品的摄入量大大增加，许多大中城市特别是经济比较发达的城市均出现了膳食纤维摄入量不足、营养素摄入不……"
        // },{
        //   id:127,
        //   title: "小常识5",
        //   content: "随着生活水平的不断提高，人们的饮食习惯已发生了很大的改变，人们对高热量、高脂肪、高蛋白食品和精细食品的摄入量大大增加，许多大中城市特别是经济比较发达的城市均出现了膳食纤维摄入量不足、营养素摄入不……"
        // }
        ]
      }
    },
    methods: {
      changeli(i) {
        this.liclass = i
      },
      gotoDetail(id) {
        console.log('getDetail:', id)
        // this.isDetail = true
        Bus.$emit('topbar', id)
      }
    }
  }
</script>

<style scoped="scoped" lang="scss">

.health-garden{

  .header-bg {
    height: 288px;
    background-color: #39f;
    > img {
      height: 100%;
      width: 100%;
    }
  }

  text-align: center;
  .tabs {
    position: absolute;
    display: flex;
    top: -43px;
    left: 7%;
  }

  .tabs-panel {
    position: relative;
    height: 30px;
  }

  .tabs > li {
    margin-left: 15px;
    font-size: 20px;
    font-weight: bold;
    display: block;
    width: 180px;
    text-align: center;
    height: 40px;
    line-height: 40px;
    background-color: white;
    border-radius: 50px;
    color: #CC9E0F;
    cursor: pointer;
    border: 5px solid #fff;
    box-shadow: 1px 2px 12px rgba(1, 1, 1, 0.12);
  }

  .bottom :hover {
    background-color: #cc9e0f;
    color: white;
  }

  .liactive {
    background-color: #cc9e0f !important;
    color: white !important;
    border: 5px solid #fff;
  }

  .content {
    text-align: left;
    padding-top: 70px;
    min-height: 500px;
    width: 80%;
    display: inline-block;
  }

  .neirong {
    width: 80%;
    transition: all .2s linear;
    // cursor: pointer;
  }

  .neirong>span {
    display: block;
    width: 100%;
  }

  .neirong>span:first-child {
    font-size: 24px;
    line-height: 30px;
    margin-bottom: 12px;
  }

  .neirong>span:nth-child(2) {
    font-size: 14px;
    line-height: 28px;
  }
  .neirong:hover{
    color: #CC9E0F;
  }
  .newsdiv {
    position: relative;
    border-top: 2px solid #D0A62A;
    padding: 30px 0;
    display: flex;
    justify-content: space-around;
    border-bottom: 2px solid #D0A62A;
    margin-bottom: -2px;
  }

  .liaojie {
    color: white;
    display: block;
    height: 32px;
    line-height: 32px;
    padding: 0 10px;
    background-color: #D0A62A;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
  }
  .reliang{
    display: block;
    margin: 0 auto;
    height: 100%;
  }
}

@media screen and (max-width: 540px) {
  .health-garden {
    .tabs {
      padding: 0;
      left: 0;
      width: 100%;
      top: -260px;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      > li {
        width: 80% !important;
        display: block;
        margin-top: 12px;
        margin-left: 0 !important;
      }
    }
    .tabs-panel {
      height: 10px;
    }
    .content {
      width: 90%;
    }
    .liaojie {
      position: absolute;
      top: 26px;
      right: 12px;
    }
    .reliang {
      width: 100%;
      padding: 0;
      margin: 0;
      overflow-x: auto;
      overflow: auto;
    }
    .jisuan {
      height: 100%;
      width: 100%;
      padding: 0 8px;
      box-sizing: border-box;

      pre {
        width: 100%;
        box-sizing: border-box;
        font-size: 15px;
      }
    }
  }
}
</style>
